<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			//去空格
			var Str="北 京";
			var Str2=Str.replace(/\s+/g,"");
			console.log(Str2); 
			
			//去回车
			window.onload = function(){
				
				function clear(element){
					for (var i=0;i<element.length;i++) {
						var node=element.childNodes[i];
						if (node.nodeType==3&&!/\s/.test(node.nodeValue)) {
							node.parentNode.removeChild(node);
						}
					}
				}
				
				clear(document.getElementById("game"));
				var a = document.getElementById("game");
				console.log(a.childNodes.length);
			}
			
		</script>
	</head>
	<body>
		<ul id="game">
			<li id="rl">红警</li>
			<li>实况</li>
			<li>极品飞车</li>
			<li>魔兽</li>
		</ul>
	</body>
</html>
